Skip to content

feat(xsender): read the answers into types generated from the core's schema - #248

Merged
carlosthe19916 merged 1 commit into
mainfrom
feat/generated-answers
Nov 16, 2026
Merged

carlosthe19916 merged 1 commit into
mainfrom
feat/generated-answers

Conversation

@carlosthe19916

Copy link
Copy Markdown
Member

Why

The SUNAT answers were typed by hand here. A field added in xhandler-rust (like the CDR's document_description) needed a hand edit in every binding, and could be silently dropped. xhandler-rust 6.0.0-alpha.2 generates them from the core's schema (project-openubl/xhandler-rust#613, docs/adrs/BINDINGS.md). This is the last step of that design: from now on, a new answer field arrives with the release's sync PR, with no hand edit.

What

  • make sync also copies the generated answers into io.github.project.openubl.xsender.models.answers (in SYNCED).
  • SunatResponses reads the core's answers into those types with Json.MAPPER, instead of reading each field by hand. A failure becomes an XhandlerException, as in XBuilder.enrich. It's split into send, verify and consult.
  • The public SunatResponse / Metadata / Sunat / Status API doesn't change. New: SunatResponse.getCdr() returns the generated CDR, so later CDR fields reach users without a hand edit.
  • The Quarkus extension registers the answers for native reflection, as xbuilder does for its models. Without this, a native build couldn't read them.
  • The answers ignore fields a newer core adds. SunatResponsesTest sends an unknown field to check this.

Verified

The xsender core tests (43) and the Quarkus xsender extension tests pass. make verify-release TAG=v6.0.0-alpha.2 passes. The native build runs in this PR's CI.

Senior review

Two passes. Findings applied:

  • clearer breaking-change notes
  • docs: CONTRIBUTING lists the generated files
  • Python's __all__ completed
  • Java uses the shared Json.MAPPER and XhandlerException, and copies the notes list

The second pass found nothing left.

🤖 Generated with Claude Code

…schema

`make sync` now also copies the SUNAT answers generated from the schema of
the core into io.github.project.openubl.xsender.models.answers (CDR, Fault,
NoCDR, ConsultStatus, Status and the answer unions), so a field added to
them in xhandler-rust arrives with the next core sync (xhandler-rust
docs/adrs/BINDINGS.md). They ignore fields a newer core adds.

SunatResponses reads the answers into them instead of field by field and
maps them to the existing SunatResponse / Metadata / Sunat API, which
doesn't change. SunatResponse.getCdr() also exposes the generated CDR, so
later CDR fields reach users without a hand edit. The Quarkus extension
registers the answers for reflection, as xbuilder does its models.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@carlosthe19916
carlosthe19916 merged commit f55c800 into main Nov 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant